function numOfUnplacedFruits(fruits, baskets) {
  const n = fruits.length;
  const used = new Array(n).fill(false); // 记录篮子是否被使用
  let unplaced = 0;

  for (let i = 0; i < n; i++) {
    const fruit = fruits[i];
    let placed = false;
    // 从左到右检查每个篮子
    for (let j = 0; j < n; j++) {
      // 找到第一个未使用且容量足够的篮子
      if (!used[j] && baskets[j] >= fruit) {
        used[j] = true;
        placed = true;
        break;
      }
    }
    if (!placed) {
      unplaced++;
    }
  }

  return unplaced;
}

// 示例测试
console.log(numOfUnplacedFruits([4, 2, 5], [3, 5, 4])); // 输出：1
console.log(numOfUnplacedFruits([3, 6, 1], [6, 4, 7])); // 输出：0
